package com.ray.controller;
/**
 * 微信消息模块
* <p>Title: WeChatToMessageController</p>  
* <p>Description: </p>  
* @author 李斌  
* @date 2018年5月11日
 */

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.google.appengine.api.search.query.ExpressionParser.negation_return;
import com.google.appengine.repackaged.com.google.protos.gdata.proto2api.Core.Response;
import com.ray.bean.DatatablesViewPageBean;
import com.ray.exception.ServiceException;
import com.ray.service.WeChatToMessageService;
import com.ray.util.RequestUtil;
import com.ray.util.ResponseUtil;
import com.ray.util.ReturnStringUtil;
import com.thoughtworks.xstream.io.naming.NameCoderWrapper;

@Controller 
@RequestMapping("/weChatToMessage")
public class WeChatToMessageController {
	
	@Autowired
	WeChatToMessageService WeChatToMessageService;
	
	
	/**
	 * 获取公司所有消息类型
	 * @param request
	 * @return
	 * @throws ServiceException
	 */
	@RequestMapping("/getAllMessageType")
	@ResponseBody
	public DatatablesViewPageBean getAllMessageType(HttpServletRequest request) throws ServiceException{
		Map map=RequestUtil.getRequestAllParam(request);
		return WeChatToMessageService.getAllMessageType(map);
	}
	
	/**
	 * 获取所有消息类型
	 * @param request
	 * @return
	 * @throws ServiceException
	 */
	@RequestMapping("/getAllType")
	@ResponseBody
	public Map getAllType(HttpServletRequest request) throws ServiceException{
		return ResponseUtil.ResponseResult(WeChatToMessageService.getAllType());
	}
	
	
	
	/**
	 * 添加消息类型
	 * @param type(消息类型)
	 * @param deptId(部门id)
	 * @param workShopId(车间id)
	 * @return
	 * @throws ServiceException
	 */
	@RequestMapping("/addMessageType")
	@ResponseBody
	public Map addMessageType(HttpServletRequest request) throws ServiceException{
		Map map=RequestUtil.getRequestAllParam(request);
		WeChatToMessageService.addMessageType(map);
		return ResponseUtil.ResponseResult(ReturnStringUtil.ADD_SUCCESS);
	}
	
	
	
	/**
	 * 添加消息类型
	 * @param id(消息类型id)
	 * @param userIdArray(用户id集合)
	 * @return
	 * @throws ServiceException
	 */
	@RequestMapping("/addTypeUser")
	@ResponseBody
	public Map addTypeUser(HttpServletRequest request) throws ServiceException{
		Map map=RequestUtil.getRequestAllParam(request);
		WeChatToMessageService.addTypeUser(map);
		return ResponseUtil.ResponseResult(ReturnStringUtil.ADD_SUCCESS);
	}
	
	
	/**
	 * 删除消息类型
	 * @param id(消息类型id)
	 * @return
	 * @throws ServiceException
	 */
	@RequestMapping("/deleteType")
	@ResponseBody
	public Map deleteType(HttpServletRequest request) throws ServiceException{
		Map map=RequestUtil.getRequestAllParam(request);
		WeChatToMessageService.deleteType(map);
		return ResponseUtil.ResponseResult(ReturnStringUtil.DELETE_SUCCESS);
	}
	
	
	/**
	 * 移除单个消息类型
	 * @param id(消息类型id)
	 * @return
	 * @throws ServiceException
	 */
	@RequestMapping("/removeTypeUser")
	@ResponseBody
	public Map removeTypeUser(HttpServletRequest request) throws ServiceException{
		Map map=RequestUtil.getRequestAllParam(request);
		WeChatToMessageService.removeTypeUser(map);
		return ResponseUtil.ResponseResult(ReturnStringUtil.REMOVE_SUCCESS);
	}
	
	/**
	 * 获取消息接收人
	 * @param id(类型id)
	 * @return
	 * @throws ServiceException
	 */
	@RequestMapping("/getTypeUser")
	@ResponseBody
	public DatatablesViewPageBean getTypeUser(HttpServletRequest request) throws ServiceException{
		Map map=RequestUtil.getRequestAllParam(request);
		return WeChatToMessageService.getTypeUser(map);
	}
	
	
	/**
	 * 获取消息中没有的接收人
	 * @param id(类型id)
	 * @param serachWhere(搜索条件)
	 * @return
	 * @throws ServiceException
	 */
	@RequestMapping("/getTypeNoHaveUser")
	@ResponseBody
	public DatatablesViewPageBean getTypeNoHaveUser(HttpServletRequest request) throws ServiceException{
		Map map=RequestUtil.getRequestAllParam(request);
		return WeChatToMessageService.getTypeNoHaveUser(map);
	}
	
	

	
	
	
	
	
	
	
	
	
	@RequestMapping("/test")
	@ResponseBody
	public Map test(HttpServletRequest request) throws ServiceException{
		Map map=RequestUtil.getRequestAllParam(request);
		return ResponseUtil.ResponseResult(WeChatToMessageService.getWeChatNewsUserIdListByMap(map));
	}
	
	
	
	
		
//	/** 
//	 * @throws ServiceException 
//	 *  添加接收消息的人
//	* @date 2018年5月11日 下午4:08:32 
//	* @author 李斌
//	* @return Map<String,Object> 
//	* @throws
//	 */
//
//	@RequestMapping("/addWeChatUser")
//	@ResponseBody
//	public Map<String, Object> addWeChatUser(HttpServletRequest request) throws ServiceException{
//		Map<String,Object> map = RequestUtil.getRequestParamByGeneric(request);
//		WeChatToMessageService.addWeChatUser(map);
//		return ResponseUtil.ResponseResult("添加成功");
//	}
//	
//	/**
//	 * 查询所以微信接收信息人员
//	* @date 2018年5月12日 下午1:38:57 
//	* @author 李斌
//	* @return Map<String,Object> 
//	* @throws
//	 */
//	@RequestMapping("/getAllWeChatUser")
//	@ResponseBody
//	public Map<String,Object> getAllWeChatUser(HttpServletRequest request) throws ServiceException{
//		Map<String,Object> map = RequestUtil.getRequestParamByGeneric(request);
//		return ResponseUtil.ResponseResult(WeChatToMessageService.getAllWeChatUser(map));
//	}
//	
//	/**
//	 * 通过userId查询微信接收信息人员
//	* @date 2018年5月12日 下午1:39:08 
//	* @author 李斌
//	* @return Map<String,Object> 
//	* @throws
//	 */
//	@RequestMapping("/getWeChatUserByUserId")
//	@ResponseBody
//	public Map<String,Object> getWeChatUserByUserId(HttpServletRequest request) throws ServiceException{
//		Map<String,Object> map = RequestUtil.getRequestParamByGeneric(request);
//		return ResponseUtil.ResponseResult(WeChatToMessageService.getWeChatUserByUserId(map));
//	}
//	
//	/**
//	 * @throws ServiceException 
//	 * 更新微信消息接收人员状态
//	* @date 2018年5月12日 下午1:39:37 
//	* @author 李斌
//	* @return Map<String,Object> 
//	* @throws
//	 */
//	@RequestMapping("/updateWeChatUserOnStatus")
//	@ResponseBody
//	public Map<String,Object> updateWeChatUserOnStatus(HttpServletRequest request) throws ServiceException{
//		Map<String,Object> map = RequestUtil.getRequestParamByGeneric(request);
//		WeChatToMessageService.updateWeChatUserOnStatus(map);
//		return ResponseUtil.ResponseResult("修改成功");
//	}
	
	
	
}
